﻿@{
    ViewBag.Title = "登录";

    ViewBag.hospitalid = "10000";
     
}


<div style="width: 550px; height: 400px; margin: 100px auto;">
    <form role="form">
        <fieldset>
            <legend>登录入口 (Login entrance)</legend>

            <div class="form-group">
                <label for="hospitalid">医院(Hospital)</label>
                @Html.DropDownList("hospitalid", (IEnumerable<SelectListItem>)ViewBag.SELECT_HOSPTIAL, "", new { @class = "notnull" })

            </div>
            <div class="form-group">
                <label for="userid">用户帐号(User account)</label>
                <input type="text" value="dba" class="form-control" id="userid" placeholder="用户帐号">
            </div>
            <div class="form-group">
                <label for="userpwd">密码(Password)</label>
                <input type="password" value="dba" class="form-control" id="userpwd" placeholder="密码">
            </div>
            <div class="form-group">
                <p class="help-block">在公共电脑上登录时，请不要勾选记住密码。(When you log in on a public computer, do not check the Remember password.)</p>
            </div>
            <div class="checkbox">
                <label>
                    <input type="checkbox">
                    记住密码(Remember password)
                </label>
            </div>


        </fieldset>
    </form>
    <button type="button" id="btn_login" class="btn btn-success">登录(Login)</button>
</div>


@section script
{
    <script type="text/javascript">
        $(function () {

            $(document.body).bind("keydown", function (evt) {
                var e = evt || widows.event;
                if (e.keyCode == "13") {
                    doLogin();
                }
            });

            //setTimeout(doLogin, 500);

            $("#btn_login").click(function () {
                doLogin();
            });

            function doLogin() {

                var param = { u: $("#userid").val(), p: $("#userpwd").val(), h: $("#hospitalid").val() };

                if (!!!param.h) {
                    alert('请输入医院');
                    $("#hospitalid").focus();
                    return;
                }
                if (!!!param.u) {
                    alert('请输入用户名');
                    $("#userid").focus();
                    return;
                }
                if (!!!param.p) {
                    alert('请输入密码');
                    $("#userpwd").focus();
                    return;
                }


                $.post("/login/dologin", param, function (msg) {

                    if (msg.flag) {
                        top.location.href = "/adm/indexv2";
                    } else {
                        mainfn.msg(msg.msg);
                    }

                });

            }

        });


    </script>
}
